package com.goodwill.androidtest.stream;

import java.util.Comparator;

public class Java8Test {
    public static void main(String[] args) {
        Comparator<Integer> com1 = new Comparator<Integer>() {

            @Override
            public int compare(Integer o1, Integer o2) {
                return Integer.compare(o1, o2);
            }
        };
        System.out.println("com1:" + com1.compare(12, 22));

        //Lambda表达式
        Comparator<Integer> com2 = ((o1, o2) -> Integer.compare(o1, o2));
        System.out.println("com2:" + com2.compare(23, 11));

        //方法引用
//        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
//            Comparator com3 = Integer :: compare;
//            System.out.println("com3:" + com3.compare(34, 45));
//        }
    }
}
